package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-27
 * Time: 14:30
 */
public class test1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()-> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        //线程还未创建处于新建状态
        System.out.println(t.getState());
        t.start();
        //线程正在运行状态处于RUNNABLE状态
        System.out.println(t.getState());
        Thread.sleep(500);
        System.out.println(t.getState());//使用sleep阻塞TIME_WAITING
        t.join();
        System.out.println(t.getState());//线程t1结束,TERMINATED状态

    }


}
